Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#526 - Provide ability to override Audio Player Controls via filter. #528

Merged
merged 4 commits into from
Jul 12, 2023

Conversation

joshuaabenazer
Copy link
Contributor

@joshuaabenazer joshuaabenazer commented Jul 6, 2023

Description of the Change

Closes #526

How to test the Change

  1. Use the newly added classifai_pre_render_post_audio_controls filter to return audio player markup, and enqueue its related styles and scripts.
  2. Check to see if the default ClassifAI plugin output for the TTS audio player is overridden as expected.

Changelog Entry

Added - Ability to override Audio Player Controls.

Credits

Props @joshuaabenazer

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@joshuaabenazer joshuaabenazer added this to the 2.2.3 milestone Jul 6, 2023
@joshuaabenazer joshuaabenazer self-assigned this Jul 6, 2023
@joshuaabenazer joshuaabenazer requested review from a team, dkotter and jeffpaul as code owners July 6, 2023 17:44
@dkotter dkotter mentioned this pull request Jul 6, 2023
18 tasks
@dkotter dkotter removed request for a team and jeffpaul July 6, 2023 20:00
$markup = apply_filters( 'classifai_pre_render_post_audio_controls', false, $content, $_post, $audio_attachment_id, $audio_attachment_url );

if ( false !== $markup ) {
return (string) $markup . $content;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious for your thoughts here @joshuaabenazer. The more I think about it, the more I lean towards just returning whatever custom markup someone adds using this new filter, instead of us prepending that to the post content.

For instance, if someone wanted to add a play button to the end of their content, this wouldn't allow them to do that. Since we pass the post content into the filter (as well as the full post object) thinking maybe it's up to whoever uses this filter to ensure they are appending/prepending the post content with their custom markup rather than us hardcoding that here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkotter Yes, I originally did not have the content appended, but I felt like it might make sense after you posted the sample code on Slack.

It would also depend on how we word the filter too, since it is namedclassifai_pre_render_post_audio_controls, I felt it gives a sense that we are in charge of the audio only.

Now come to think of it we should just give the control to the developer as that might make it a little less confusing of what is expected. If you agree, then I can work on making that change and possibly change the filter nomenclature too(?)
I will be able to pick this up early next week though as I sign off early on Fridays.

Also originally I was just going to supply $content and $audio_attachment_url params to the filter since mostly we would need that only and the remaining can be derived if needed, but it is good to provide the other params since we have it already.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you agree, then I can work on making that change and possibly change the filter nomenclature too(?)
I will be able to pick this up early next week though as I sign off early on Fridays.

Yeah, this sounds good to me 👍🏻

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshuaabenazer Let me know if you want me to finish this off. Hoping to get a 2.2.3 release out this week and would love to include this if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkotter got sidetracked by other priorities. I may be able to get to this on Friday or early next week. That being said I don't mind you taking over to finish this off too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in looking at this again, I've changed my mind and going to merge this in as-is. Looking at the render_post_audio_controls method, it builds the audio markup and prepends that to the post content. So I think having this custom filter do the same thing (take whatever custom markup someone provides and then prepending it to the post content) is fine. If we get complaints or use cases that this doesn't support, happy to look at changing this in the future

@dkotter
Copy link
Collaborator

dkotter commented Jul 6, 2023

Made a few PHPCS changes and some wording tweaks but tested and this works good. Left one comment to discuss but then this can get merged in

@dkotter dkotter merged commit e2ee0c3 into develop Jul 12, 2023
@dkotter dkotter deleted the feature/526-overrride-audio-player branch July 12, 2023 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to override audio player on post
2 participants